#ifndef SWP_PROJECT_DOCUMENT_H
#define SWP_PROJECT_DOCUMENT_H

#include "data/navigatordata.h"

#include <icontainerdocument.h>
#include <mimetype.h>

#include <QtCore/QHash>

namespace swp
{

class SwpProjectDocument : public core::IContainerDocument
{
    Q_OBJECT

public:
    SwpProjectDocument(const QString& name, const core::MimeType& mimeType);
    ~SwpProjectDocument();

    // IDocument
    void setValid(bool valid);
    bool isValid() const;

    bool isFuture() const;

    bool isLinked() const;
    bool isContainer() const;

    bool isDirty() const;
    QString name() const;

    core::MimeType mimeType() const;

    QSharedPointer<IContainerDocument> container() const;

    void setDirty(bool dirty = true);
    void setFuture(bool future = true);
    void setContainer(
        const QSharedPointer<core::IContainerDocument>& container);

    void rename(const QString& name);

    core::IDocumentData* data() const;

    // IContainerDocument
    core::DocumentCategories categories() const;

    QList<QSharedPointer<core::IDocument> > documents(
        const QString& categoryName) const;
    QList<core::MimeType> categoryMimeTypes(
            const QString& categoryName) const;

    QString categoryFor(
        const QSharedPointer<IDocument>& document) const;

    bool isTopLevel() const;

    void addDocument(const QString& categoryName,
        const QSharedPointer<core::IDocument>& document);

    void removeDocument(const QString& categoryName,
        const QSharedPointer<core::IDocument>& document);
    void removeDocument(const QSharedPointer<core::IDocument>& document);

    bool isChildrenDirty() const;

    void linksUpdated();

private:
    QString m_name;
    core::MimeType m_mimeType;
    bool m_isDirty;
    QHash<QString, QList<QSharedPointer<core::IDocument> > > m_documents;
    mutable NavigatorData m_data;
};

} // namespace swp

#endif
